﻿using System;
using SimpleServiceBus.Bus.MessageManagement.MessageHandling;
using SimpleServiceBus.Bus.Pipeline;
using SimpleServiceBus.Messages.Management.Monitoring;

namespace SimpleServiceBus.Endpoint.Management.Monitoring
{
    public class EndpointPingRequestHandler : IMessageHandler<EndpointPingRequest>
    {
        public void Handle(EndpointPingRequest message, IMessageContext context)
        {
            string reply = context.Endpoint.Metadata.EndpointID + " at " + context.Endpoint.Metadata.ReturnAddress +
                           " OK at " + DateTime.Now.ToUniversalTime() + " UTC";
            context.Endpoint.MessageBus.Reply(new EndpointPingResponse{Message=reply});
        }

    }
}